/*     */ package com.chinapay.secss;
/*     */ 
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import java.util.Properties;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class SecssConfig
/*     */ {
/*  19 */   private static String FILE_NAME = "security.properties";
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private String signFile;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private String signFileAlias;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private String signFilePwd;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private String signCertType;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private String verifyFile;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private String signFieldName;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private List invalidFileds;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static SecssConfig defaultInit() throws SecurityException {
/*  62 */     SecssConfig secssConfig = null;
/*  63 */     Properties pros = loadPropertiesFromSrc();
/*  64 */     if (checkPros(pros)) {
/*  65 */       secssConfig = new SecssConfig();
/*  66 */       secssConfig.loadProperties(pros);
/*     */     } 
/*     */     
/*  69 */     return secssConfig;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static SecssConfig specifyInit(Properties pros) throws SecurityException {
/*  82 */     SecssConfig secssConfig = null;
/*  83 */     if (checkPros(pros)) {
/*  84 */       secssConfig = new SecssConfig();
/*  85 */       secssConfig.loadProperties(pros);
/*     */     } 
/*  87 */     return secssConfig;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private static Properties loadPropertiesFromSrc() throws SecurityException {
/*  97 */     InputStream in = null;
/*  98 */     Properties properties = null;
/*     */     try {
/* 100 */       in = SecssConfig.class.getClassLoader().getResourceAsStream(
/* 101 */           FILE_NAME);
/* 102 */       if (in != null) {
/* 103 */         properties = new Properties();
/*     */         try {
/* 105 */           properties.load(in);
/* 106 */         } catch (IOException e) {
/* 107 */           throw e;
/*     */         } 
/*     */       } 
/*     */       
/* 111 */       if (in != null) {
/*     */         try {
/* 113 */           in.close();
/* 114 */         } catch (IOException iOException) {}
/*     */       }
/*     */ 
/*     */       
/* 118 */       return properties;
/* 119 */     } catch (IOException e) {
/* 120 */       LogUtil.writeErrorLog("加载配置文件异常！", e);
/* 121 */       if (in != null) {
/*     */         try {
/* 123 */           in.close();
/* 124 */         } catch (IOException iOException) {}
/*     */       }
/*     */ 
/*     */       
/* 128 */       throw new SecurityException(SecssConstants.LOAD_CONFIG_ERROR);
/*     */     } finally {
/* 130 */       if (in != null) {
/*     */         try {
/* 132 */           in.close();
/* 133 */         } catch (IOException iOException) {}
/*     */       }
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void loadProperties(Properties pro) {
/* 147 */     String value = pro.getProperty(SecssConstants.SIGN_FILE);
/* 148 */     if (!SecssUtil.isEmpty(value)) {
/* 149 */       this.signFile = value.trim();
/*     */     }
/* 151 */     value = pro.getProperty(SecssConstants.SIGN_FILE_ALIAS);
/* 152 */     if (!SecssUtil.isEmpty(value)) {
/* 153 */       this.signFileAlias = value.trim();
/*     */     }
/* 155 */     value = pro.getProperty(SecssConstants.SIGN_FILE_PW);
/* 156 */     if (!SecssUtil.isEmpty(value)) {
/* 157 */       this.signFilePwd = value.trim();
/*     */     }
/* 159 */     value = pro.getProperty(SecssConstants.VERIFY_FILE);
/* 160 */     if (!SecssUtil.isEmpty(value)) {
/* 161 */       this.verifyFile = value.trim();
/*     */     }
/* 163 */     value = pro.getProperty(SecssConstants.SIGN_CERT_TYPE);
/* 164 */     if (!SecssUtil.isEmpty(value)) {
/* 165 */       this.signCertType = value.trim();
/*     */     }
/* 167 */     value = pro.getProperty(SecssConstants.SIGNATURE_FIELD);
/* 168 */     if (!SecssUtil.isEmpty(value)) {
/* 169 */       this.signFieldName = value.trim();
/*     */     }
/* 171 */     value = pro.getProperty(SecssConstants.SIGN_INVALID_FIELDS);
/* 172 */     if (!SecssUtil.isEmpty(value)) {
/* 173 */       String localValue = value.trim();
/* 174 */       String[] values = localValue.split(",");
/* 175 */       if (values != null && values.length > 0) {
/* 176 */         this.invalidFileds = new ArrayList();
/* 177 */         for (int i = 0; i < values.length; i++) {
/* 178 */           this.invalidFileds.add(values[i].trim());
/*     */         }
/*     */       } 
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private static boolean checkPros(Properties pro) throws SecurityException {
/* 193 */     if (SecssUtil.isEmpty(pro.getProperty(SecssConstants.SIGN_FILE))) {
/* 194 */       throw new SecurityException(SecssConstants.CONFIG_WRONG);
/*     */     }
/* 196 */     if (SecssUtil.isEmpty(pro.getProperty(SecssConstants.SIGN_FILE_PW))) {
/* 197 */       throw new SecurityException(SecssConstants.CONFIG_WRONG);
/*     */     }
/* 199 */     if (SecssUtil.isEmpty(pro.getProperty(SecssConstants.VERIFY_FILE))) {
/* 200 */       throw new SecurityException(SecssConstants.CONFIG_WRONG);
/*     */     }
/* 202 */     if (SecssUtil.isEmpty(pro.getProperty(SecssConstants.SIGN_CERT_TYPE))) {
/* 203 */       throw new SecurityException(SecssConstants.CONFIG_WRONG);
/*     */     }
/* 205 */     if (SecssUtil.isEmpty(pro.getProperty(SecssConstants.SIGNATURE_FIELD))) {
/* 206 */       throw new SecurityException(SecssConstants.CONFIG_WRONG);
/*     */     }
/* 208 */     return true;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String getSignFile() {
/* 216 */     return this.signFile;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String getSignFilePwd() {
/* 224 */     return this.signFilePwd;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String getVerifyFile() {
/* 232 */     return this.verifyFile;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String getSignCertType() {
/* 240 */     return this.signCertType;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String getSignFieldName() {
/* 248 */     return this.signFieldName;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public List getInvalidFileds() {
/* 255 */     return this.invalidFileds;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String getSignFileAlias() {
/* 264 */     return this.signFileAlias;
/*     */   }
/*     */ }


/* Location:              C:\Users\Administrator\Downloads\jd-gui-windows-1.6.6\jd-gui-windows-1.6.6\chinapay-secure-1.5.1.jar!\com\chinapay\secss\SecssConfig.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       1.1.3
 */